﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;
public partial class Admin_ImageAdmin : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            try
            {
                DirectoryInfo dirMedia = new DirectoryInfo(Server.MapPath("~/media/"));
                DirectoryInfo[] dirInfo = dirMedia.GetDirectories();

                for (int i = 0; i < dirInfo.Length; i++)
                {
                    DropDownList1.Items.Add(dirInfo[i].ToString());
                }

            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message.ToString();
            }
        }

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string dirName = DropDownList1.SelectedItem.ToString();
        string pathName =  "~/media/"+dirName+"/";
        try 
        {
            FileUpload1.PostedFile.SaveAs(Server.MapPath(pathName+FileUpload1.FileName));
        }
        catch (Exception ex)
        {
            lblError.Text = ex.Message.ToString();
        }
    }
}
